/**
 * @author xuzj
 */
CQCIS.Button = Ext.extend(Ext.Button, {
    initComponent: function(){
        var shortcutKey = this.text.match(/\<u>([A-Za-z0-9,\-\/]*)<\/u>/);
        if (shortcutKey) {
            if (this.KeyMap) {
                this.KeyMap.addBinding({
                    key: shortcutKey[1],
                    alt: true,
                    scope: this,
                    fn: function(){
                        if (this.hasListener('click')) {
                            this.fireEvent('click');
                        } else {
                            this.handler();
                        }
                    }
                });
            } else {
                this.KeyMap = new Ext.KeyMap(document, {
                    key: shortcutKey[1],
                    alt: true,
                    scope: this,
                    fn: function(){
                        var mask = Ext.query('div.ext-el-mask{display!=none}');
                        if (mask && mask.length > 0) {
                            return false;
                        } else {
                            if (this.hasListener('click')) {
                                this.fireEvent('click');
                            } else {
                                this.handler();
                            }
                        }
                    }
                });
            }
        }
        this.tooltip = shortcutKey ? '快捷键：alt + ' + shortcutKey[1] : undefined;
        CQCIS.form.WinForm.superclass.initComponent.call(this);
    }
});
